Securing Ubuntu (22.04 LTS)
Follow these steps to secure Ubuntu:
-
Restrict SU Access:
-
Log in to Ubuntu 22.04 server using a non-root account.
-
Use the command
su
to change switch user, to gain the privileges granted to other user. To create a new admin group on the server, use the following commands:Copysudo groupadd admin
sudo usermod -a -G admin jack
sudo dpkg-statoverride --update --add root admin 4750 /bin/suIf you log in to your Ubuntu server as the user jack and attempt to use the
su
command to switch to another user, it is allowed because jack is a member of admin. Other users are denied access to thesu
command.
-
-
Use authentication Key pair to log to your server:
-
By default, you log into the system through SSH with a username and a password.
Using a private/public key is considered safe because the keys are tough to guess. You can generate the authentication keys utilizing an application like PuTTY Key Generator.
-
Upload the public key on your Ubuntu server on the file:
<username>/.ssh/authorized_keys
-
-
Shared memory can be used in an attack against a running service. Perform the following step:
-
You can do this by modifying the /etc/fstab file.
-
Add - tmpfs /run/shm tmpfs defaults,noexec,nosuid 0 0.
-
Save and reboot the system
-
Implement default firewall of Ubuntu using Iptables and perform the following steps:
-
Go for whitelisting approach
-
Change default to deny/drop
- Change Auditing to ON